package 最大数;

import java.util.Arrays;

class Solution {
    public String largestNumber(int[] nums) {
        int n = nums.length;
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = "" + nums[i];
        }
        Arrays.sort(s, (a, b) -> {
            return (b + a).compareTo(a + b);
        });
        StringBuilder ret = new StringBuilder();
        for (int i = 0; i < n; i++) {
            ret.append(s[i]);
        }
        if (ret.charAt(0) == '0') {
            return "0";
        }
        return ret.toString();
    }
}
